package cn.chinaiptv.apkmanager.serverlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.chinaiptv.apkmanager.bean.Epgrecomm;
import cn.chinaiptv.apkmanager.dao.EPGRecommDao;

public class AddEpgRecommServerlet extends HttpServlet {

	private String platform;
	private String poscode;
	private String title;
	private String icon;
	private String linktype;
	private int linktypeInt;
	private String linkobjvalue;
	private String status;
	private int statusInt;
	private String validtime;
	private String expiretime;
	private String linkobjtype;

	@Override
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(request, response);
		platform = request.getParameter("platform");
		poscode = request.getParameter("poscode");
		title = request.getParameter("title");
		icon = request.getParameter("icon");
		linktype = request.getParameter("linktype");
		linkobjvalue = request.getParameter("linkobjvalue");
		status = request.getParameter("status");
		linkobjtype = request.getParameter("linkobjtype");
		validtime = request.getParameter("validtime");
		expiretime = request.getParameter("expiretime");
		linktypeInt = Integer.parseInt(linktype);
		statusInt = Integer.parseInt(status);
		Epgrecomm bean = new Epgrecomm(platform, "configpos", poscode, title,
				icon, linktypeInt, linkobjtype, linkobjvalue, statusInt,
				validtime, expiretime);
		boolean result = EPGRecommDao.save(bean);
		String resutlJson = "{" + "\"success\":" + result + "}";
		PrintWriter out = response.getWriter();
		out.print(resutlJson);

	}
}
